from django.db import models

# Create your models here.

class Staff(models.Model):
    '''员工基础信息模型'''
    name = models.CharField(verbose_name='姓名', max_length=32)
    Sexs = (
        ('1','男'),
        ('2', '女'),
        ('3', '妖'),
    )
    sex = models.CharField(verbose_name='性别', max_length=2, choices=Sexs)
    age = models.IntegerField(verbose_name='年龄')
    shengri = models.DateField(verbose_name='生日')
    address = models.CharField(verbose_name='办公地点', max_length=100, blank=True)
    staff_name = models.ForeignKey('Department', verbose_name='所属部门', on_delete=models.CASCADE, blank=True, null=True)
    subjects = models.ManyToManyField('Subjects', verbose_name='选修课程')
    class Meta:
        verbose_name = '员工信息'
        verbose_name_plural = '员工信息'
    def __str__(self):
        return self.name



class Department(models.Model):
    '''部门模型'''
    department_name = models.CharField(verbose_name='部门', max_length=100)
    headmaster = models.OneToOneField('Teachers', verbose_name='讲师', on_delete=models.CASCADE, blank=True, null=True)
    class Meta:
        verbose_name = '部门'
        verbose_name_plural= '部门'
        
    def __str__(self):
        return self.department_name
    
    
class Subjects(models.Model):
    '''课程模型'''
    name = models.CharField(verbose_name='课程名称', max_length=50, blank=True)
    score = models.IntegerField(verbose_name='学分', blank=True)

    class Meta:
        verbose_name = '课程信息'
        verbose_name_plural = '课程信息'

    def __str__(self):
        return self.name
    
class Teachers(models.Model):
    '''教师Model'''
    name = models.CharField(verbose_name='教师姓名', max_length=50)
    class Meta:
        verbose_name = '讲师信息'
        verbose_name_plural = '讲师信息'

    def __str__(self):
        return self.name